Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(multichain): fusdc "advance and settle" as a macro #10692

Merged
merged 3 commits into from
Dec 17, 2024

Conversation

0xpatrickdev
Copy link
Member

refs: #10597

Description

  • tests additional FUSDC happy paths with agoric and noble EUDs
  • "oracles accept" test conditionally accepts invitations

Security Considerations

None, only tests

Scaling Considerations

None, ~60s hit to CI (each advance + settle is about 30s)

Documentation Considerations

None

Testing Considerations

PR is only tests

Upgrade Considerations

None

@@ -34,7 +34,7 @@ const accounts = [...keys(oracleMnemonics), 'lp'];
const contractName = 'fastUsdc';
const contractBuilder =
'../packages/builders/scripts/fast-usdc/init-fast-usdc.js';
const LP_DEPOSIT_AMOUNT = 10_000_000n;
const LP_DEPOSIT_AMOUNT = 8_000n * 10n ** 6n;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have the 10^6 as a constant somewhere but this is clear enough. better than the literal

'published.agoricNames.instance',
);
const instance = fromEntries(instances)[contractName];
// TODO export/import INVITATION_MAKERS_DESC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not be imported. the test should be declaring what it expects the value to be, not just that it matches something else.

consider if someone changed the value in the other module. the test should fail and have to be updated to make clear that the API changed.

);
const instance = fromEntries(instances)[contractName];
// TODO export/import INVITATION_MAKERS_DESC
const ORACLE_INV_DESC = 'oracle operator invitation';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the reason above I think this shouldn't have ALL_CAPS casing. defining the value at all is just a convenience in this function to not have to repeat it.


```suggestion
  const description = 'oracle operator invitation';

@0xpatrickdev 0xpatrickdev force-pushed the pc/fusdc-multichain-macro branch from 57494a3 to 4a1e603 Compare December 13, 2024 17:30
Copy link

cloudflare-workers-and-pages bot commented Dec 13, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4ce1540
Status: ✅  Deploy successful!
Preview URL: https://1c8772b1.agoric-sdk.pages.dev
Branch Preview URL: https://pc-fusdc-multichain-macro.agoric-sdk.pages.dev

View logs

Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to talk over a suggestion to factor out roles / participants with makeOracleOperator(...) and such.

const hasInvitation = invitations.some(
x => x.description === ORACLE_INV_DESC,
);
const usedInvitation = offerToUsedInvitation?.[0]?.[0] === `${name}-accept`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const usedInvitation = offerToUsedInvitation?.[0]?.[0] === `${name}-accept`;
const usedInvitation = offerToUsedInvitation.some(([id, _v]) => id === `${name}-accept`);


// ensure we have an unused (or used) oracle invitation in each purse
let hasAccepted = false;
for (const name of keys(oracleMnemonics)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot going on in this loop.

If we reify the oracle operators as objects somewhat like makeOracleOperator or makeAgoricWatcher, we can make this read much more straightforwardly:

Suggested change
for (const name of keys(oracleMnemonics)) {
for (const op of oracleOperators) {
const status = await oracle.invitationCheck(); // returns the invitation or `used` if used;
t.log({ name: op.name, status });
t.truthy(status);
}

t.true(hasInvitation || usedInvitation, 'has or accepted invitation');
if (usedInvitation) hasAccepted = true;
}
// if the oracles have already accepted, skip the rest of the test this is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// if the oracles have already accepted, skip the rest of the test this is
// if any of the oracles have already accepted, skip the rest of the test this is

right?

);
t.log('settlementAccount address', settlementAccount);
const advanceAndSettleScenario = test.macro({
title: (_, mintAmt: bigint, eudChain: string) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eudChain is kinda... tortured

Suggested change
title: (_, mintAmt: bigint, eudChain: string) =>
title: (_, mintAmt: bigint, destChain: string) =>

} = t.context;

// EUD wallet on the specified chain
const eudWallet = await createWallet(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likewise...

Suggested change
const eudWallet = await createWallet(
const destWallet = await createWallet(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather avoid using the ambient random source inside createWallet. I don't suppose we have a widget where you pass crypto.randomBytes(plenty) and it makes a mnemonic, do we? Or can we pass in a private key?

I can imagine this isn't worthwhile just now, so... adding it to the list:

aux: {
forwardingChannel: nobleAgoricChannelId,
// register forwarding address on noble
const txRes = nobleTools.registerForwardingAcct(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, lots going on; my tiny brain wants the roles (user, noble chain, ...) reified as objects.


// submit evidences
await Promise.all(
oracleWds.map(makeDoOffer).map((doOffer, i) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would love to see...

Suggested change
oracleWds.map(makeDoOffer).map((doOffer, i) =>
oracleOperators.map(op => op.submit(evidence));

Base automatically changed from pc/provision-sw-flake to master December 13, 2024 18:19
Copy link

Base branch is changed to master. Please re-run the integration tests by adding 'force:integration' label.

const { offerToUsedInvitation, purses } = await vstorageClient.queryData(
`published.wallet.${wallets[name]}.current`,
);
const { value: invitations } = balancesFromPurses(purses)[Invitation];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that work?

balancesFromPurses returns a map, right? and Invitation is a Brand

operators.map(async op => {
const { invitation, usedInvitation } = await op.checkInvitation();
t.log({ name: op.getName(), invitation, usedInvitation });
t.true(invitation || usedInvitation, 'has or accepted invitation');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this map function return usedInvitation for the logic below to work? If it doesn't return anything then checks.some(Boolean) would always be false right?

@dckc dckc force-pushed the pc/fusdc-multichain-macro branch 5 times, most recently from 3ee3fbe to 6134570 Compare December 14, 2024 00:18
@dckc dckc added the force:integration Force integration tests to run on PR label Dec 14, 2024
@dckc dckc force-pushed the pc/fusdc-multichain-macro branch 4 times, most recently from 44f280c to e084cac Compare December 15, 2024 04:40
@dckc dckc force-pushed the pc/fusdc-multichain-macro branch from e084cac to 4a1e603 Compare December 16, 2024 03:25
@dckc
Copy link
Member

dckc commented Dec 16, 2024

I haven't gotten set up to test this locally; using ci to test it is pretty slow.

Let's roll back to before @0xpatrickdev handed this to me and see if it's green. If so, I can do my refactor in a follow-on.

@dckc
Copy link
Member

dckc commented Dec 16, 2024

No quorum: flake in z:acceptance governance?

flake?

[z:acceptance] Running test.sh.

ACCEPTANCE TESTING governance
...

  ✘ [fail]: economic committee can make governance proposal and vote on it
...
        reason: 'No quorum',
...
Error: Command failed: docker run -e SLOGFILE -v "$SLOGFILE:/home/runner/test.slog" --rm ghcr.io/agoric/agoric-3-proposals:test-acceptance

Mon, 16 Dec 2024 04:10:39 GMT

@dckc dckc added the automerge:rebase Automatically rebase updates, then merge label Dec 17, 2024
0xpatrickdev and others added 3 commits December 17, 2024 00:16
- include `agoric` and `noble` EUD destinations
- mainly to facilitate active development; allows test to be run more than once
@0xpatrickdev 0xpatrickdev force-pushed the pc/fusdc-multichain-macro branch from 295e818 to 4ce1540 Compare December 17, 2024 00:16
Copy link
Contributor

mergify bot commented Dec 17, 2024

This pull request has been removed from the queue for the following reason: checks failed.

The merge conditions cannot be satisfied due to failing checks:

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.

If you want to requeue this pull request, you need to post a comment with the text: @mergifyio requeue

@dckc
Copy link
Member

dckc commented Dec 17, 2024

psm acceptance flake?

in a3p-integration/proposals/z:acceptance/psm.test.js

https://github.com/Agoric/agoric-sdk/actions/runs/12363738833/job/34505666038?pr=10692#step:10:8349

@mergify mergify bot merged commit 9e124c3 into master Dec 17, 2024
81 checks passed
@mergify mergify bot deleted the pc/fusdc-multichain-macro branch December 17, 2024 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge force:integration Force integration tests to run on PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants